<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'header.php'?>
<style type="text/css">
	#import {
		position: relative;
		top: 1.4px;
	}
	#import-class {
		position: relative;
		top: 1.4px;
	}
	a:hover {
		text-decoration: none;
	}
</style>
<div class="page-header">
	<h1 style="font-size: 20px;">
		<a class="a-back" href="<?= admin_url('brand/power_time/') ?>">
            <i class="fa fa-reply"></i>
        </a>
		年级自定义时间		
	</h1>
</div>

<div class="col-xs-12">
	<table id="dynamic-table" class="table table-striped table-bordered table-hover" style="margin-top:10px">
		<thead>
			<tr>
				<th>年级名称</th>
				<th>自定义开机时间</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>
<!-- 放假弹窗 -->
<div id="modal-holiday" class="modal fade">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					<span>放假时间</span>
				</div>
			</div>
			<div class="modal-body no-padding">
				<div class="row">
					<div class="col-xs-12">
						<form class="form-horizontal mt10">
							<div class="form-group mb10">
								<a href="javascript:;" class="col-sm-3 control-label bolder blue create-holiday" style="margin-left:10px;"><i class="fa fa-plus"></i> 添加放假时间</a>
							</div>
							<div id="holiday-div"></div>
						</form>
					</div>
				</div>
			</div>
			<div class="modal-footer no-margin-top" >
				<a href="javascript:;" class="btn btn-sm btn-primary" id="save-holiday">
					<i class="ace-icon fa fa-check"></i> 保存
				</a>
			</div>
		</div>
	</div>
</div>
<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<script type="text/javascript">
	$(function(){
		// 年级表格
		$('#dynamic-table').dt({
			"ajaxUrl": '<?=admin_url('brand/get_grade_power_time_list')?>',
			"columns": [
				{"data": "grade_name"},
	            {"data": function(ret){
					var powerStr = "";
					if(ret.gradePowerTime == '<?=$powertime?>') {
	            		powerStr = '<a class="power-time" href="<?= admin_url('brand/grade_power_time_detail/') ?>'+ ret.id +'">未设置 <i class="fa fa-edit"></i></a>';
	            	} else {
	            		powerStr = '<a class="power-time text-danger" href="<?= admin_url('brand/grade_power_time_detail/') ?>'+ ret.id +'">自定义时间 <i class="fa fa-edit"></i></a>';
	            	}
	            	return powerStr;
				}}
			]
		});
		
	})
	
	// 生成放假时间
	function create_holiday_item(startDate, endDate) {
		$("#holiday-div").append('<div class="form-group mg0">\
			<div class="col-sm-1"></div>\
			<div class="alert alert-success col-sm-10">\
				<button type="button" class="close" data-dismiss="alert">\
					<i class="ace-icon fa fa-times"></i>\
				</button>\
                <input class="datepicker holiday-input" name="date-start" value="'+ startDate +'" /> ~ &nbsp; <input class="datepicker holiday-input" name="date-end" value="'+ endDate +'" />\
			</div>\
        </div>');
        var today = "<?= date('Y-m-d') ?>";
        $(".datepicker").datepicker({
			autoclose: true,
			todayHighlight: true,
			startDate: "<?= date('Y-m-d') ?>"
        });
    }
</script>